//
//  AddInvoicesVC.m
//  Xiaomakuaixiu
//
//  Created by SunChao on 2018/4/7.
//  Copyright © 2018年 hwd. All rights reserved.
//

#import "AddInvoicesVC.h"
#import "AddInvoiceCell.h"
@interface AddInvoicesVC ()<UITableViewDataSource,UITableViewDelegate>
{
    NSArray *_titleArr;
    
}
@property (nonatomic,strong)UITableView *tbView;


@end

@implementation AddInvoicesVC

- (void)viewDidLoad {
    [super viewDidLoad];
    _titleArr = @[@"公司名称",@"公司税号",@"公司地址",@"公司电话",@"开户银行",@"银行账户"];

    CGRect tabFrame = CGRectMake(0, 0, kScreen_width, kScreen_height-QLM_StatusBarAndNavigationBarHeight-IOS11_OR_LATER_SPACE(34)-40);
    
    _tbView=[[UITableView alloc] initWithFrame:tabFrame style:UITableViewStylePlain];
    _tbView.backgroundColor=[UIColor clearColor];
    _tbView.delegate=self;
    _tbView.dataSource=self;
    _tbView.separatorStyle=UITableViewCellSeparatorStyleNone;
    _tbView.showsVerticalScrollIndicator=NO;
    _tbView.showsHorizontalScrollIndicator=NO;
    _tbView.tableFooterView=[UIView new];
    _tbView.tableHeaderView=[UIView new];
    [self.view addSubview:_tbView];
    
    
    UIView *topBackView=[[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreen_width, 40)];
    topBackView.backgroundColor=[UIColor whiteColor];
    NSString *telStr=@"* 请确保您填写信息的准确性，包含英文输入法下的括号，您每天有10次校验机会";
    NSMutableAttributedString *aString=[[NSMutableAttributedString alloc] initWithString:telStr];
    [aString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 1)];
    
    UILabel *addreTipLabel=[[UILabel alloc] initWithFrame:CGRectMake(20, 0, kScreen_width-40, 40)];
    addreTipLabel.font=[UIFont systemFontOfSize:13];
    addreTipLabel.numberOfLines=0;
    addreTipLabel.textColor=[UIColor blackColor];
    addreTipLabel.attributedText=aString;
    addreTipLabel.textAlignment=NSTextAlignmentLeft;
    [topBackView addSubview:addreTipLabel];
    _tbView.tableHeaderView = topBackView;
    
    UIImageView *backImageView=[[UIImageView alloc]initWithFrame:_tbView.frame];
    [backImageView setImage:[UIImage imageNamed:@"fgx12.png"]];
    _tbView.backgroundView=backImageView;
    [_tbView registerNib:[UINib nibWithNibName:@"AddInvoiceCell" bundle:nil] forCellReuseIdentifier:@"AddInvoiceCell"];
    
    if (@available(iOS 11.0, *)) {
        _tbView.contentInsetAdjustmentBehavior=UIScrollViewContentInsetAdjustmentNever;
    } else {
        // Fallback on earlier versions
        self.automaticallyAdjustsScrollViewInsets = NO;
    }
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return _titleArr.count;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    AddInvoiceCell *cell = [tableView dequeueReusableCellWithIdentifier:@"AddInvoiceCell"];
    cell.backgroundColor = [UIColor clearColor];
    cell.titleLabel.text = [_titleArr objectAtIndex:indexPath.row];
    cell.dataTextField.text = @"请输入";
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

@end
